﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.Linq;
using System.Text;

namespace KC.ExtensionMethods
{
	public static class IQueryables
	{
		/// <summary>Returns page n of an IQueryable result set.</summary>
		/// <param name="query">IQueryable object</param>
		/// <param name="pageNumber">Page number to retrieve</param>
		/// <param name="pageSize">Size of the pages</param>
		/// <returns>Page n of query</returns>
		public static IQueryable<object> Page(this IQueryable<object> query, int pageNumber, int pageSize)
		{
			return query.Skip((pageNumber - 1) * pageSize).Take(pageSize);
		}
	}
}
